package com.sls.game.dao.impl.jpay;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.sls.game.dao.impl.SuperDAO;
import com.sls.game.dao.jpay.JpayGoodsDAO;
import com.sls.game.page.Pagination;
import com.sls.game.pojo.jieyitong.JieyitongGoodsInfo;

@Repository("jpayGoodsDAO")
public class JpayGoodsDAOImpl extends SuperDAO<JieyitongGoodsInfo> implements
		JpayGoodsDAO {

	@Override
	public void insert(JieyitongGoodsInfo jInfo) {
		this.getSqlSession().insert(
				"mybatis.xml.JieyitongGoodsInfoMapper.insert", jInfo);
	}

	@Override
	public void update(JieyitongGoodsInfo jInfo) {
		this.getSqlSession().update(
				"mybatis.xml.JieyitongGoodsInfoMapper.update", jInfo);
	}

	@Override
	public JieyitongGoodsInfo queryById(String id) {
		return this.getSqlSession().selectOne(
				"mybatis.xml.JieyitongGoodsInfoMapper.selectByPrimaryKey", id);
	}

	@Override
	public Pagination<JieyitongGoodsInfo> queryPaginationList(
			JieyitongGoodsInfo jInfo) {
		Pagination<JieyitongGoodsInfo> paginationList = null;
		Integer rowCount = queryRowCount(jInfo);
		jInfo.calculate();
		List<JieyitongGoodsInfo> list = queryGoodsInfoList(jInfo);
		paginationList = this.queryPagination(rowCount, list, jInfo);
		return paginationList;
	}

	/**
	 * 查询记录总数
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private Integer queryRowCount(JieyitongGoodsInfo jInfo) {
		Integer rowCount = this.getSqlSession().selectOne(
				"mybatis.xml.JieyitongGoodsInfoMapper.queryRowCount", jInfo);
		return rowCount;
	}

	/**
	 * 记录结果集list
	 * 
	 * @param enLinkGoodsInfo
	 * @return
	 */
	private List<JieyitongGoodsInfo> queryGoodsInfoList(JieyitongGoodsInfo jInfo) {
		List<JieyitongGoodsInfo> list = this.getSqlSession().selectList(
				"mybatis.xml.JieyitongGoodsInfoMapper.queryJpayGoodsInfoList",
				jInfo);
		return list;
	}

	@Override
	public List<JieyitongGoodsInfo> queryAllJpayInfo(JieyitongGoodsInfo isAudit) {
		List<JieyitongGoodsInfo> list = this.getSqlSession().selectList(
				"mybatis.xml.JieyitongGoodsInfoMapper.queryAllJpayInfo",
				isAudit);
		return list;
	}

	@Override
	public JieyitongGoodsInfo queryByGoodsId(String goodsId) {
		return this.getSqlSession().selectOne(
				"mybatis.xml.JieyitongGoodsInfoMapper.queryByGoodsId", goodsId);
	}

	/**
	 * 查询所有商品编号
	 * 
	 * @return
	 */
	@Override
	public List<JieyitongGoodsInfo> queryAllGoodsId() {
		List<JieyitongGoodsInfo> list = null;
		list = this.getSqlSession().selectList(
				"mybatis.xml.JieyitongGoodsInfoMapper.queryAllGoodsId");

		return list;
	}

}
